package edu.unmsm.ocaa.sisocaa.integracion.dao.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import com.ibatis.sqlmap.client.SqlMapClient;

import edu.unmsm.ocaa.sisocaa.integracion.dao.TipoPersonaDAO;
import edu.unmsm.ocaa.sisocaa.negocio.model.dto.TipoPersonaDTO;

@Repository
public class TipoPersonaDAOImpl extends SqlMapClientDaoSupport implements TipoPersonaDAO {

	@Autowired
	public TipoPersonaDAOImpl(SqlMapClient sqlmap) {
		super.setSqlMapClient(sqlmap);
		// TODO Auto-generated constructor stub
	}

	@Override
	public TipoPersonaDTO getTipoPer(Integer idTipoper)
			throws DataAccessException {
		return (TipoPersonaDTO)getSqlMapClientTemplate().queryForObject("getTipoPersona", idTipoper);
	}

	@Override
	public List<TipoPersonaDTO> getTipoPerxDsc(String dscTiper) {
		return (List<TipoPersonaDTO>)getSqlMapClientTemplate().queryForList("getTipoPersonaxDsc", dscTiper);
	}

	@Override
	public void insertTipPer(TipoPersonaDTO tipPer) {
		getSqlMapClientTemplate().insert("insertTipoPersona", tipPer);
	}

	@Override
	public void deleteTipPer(Integer id_tipoper) {
		getSqlMapClientTemplate().delete("deleteTipoPersona", id_tipoper);
	}

	@Override
	public void updateTipPer(TipoPersonaDTO tipPer) {
		getSqlMapClientTemplate().delete("updateTipoPersona", tipPer);
	}

	@Override
	public List<TipoPersonaDTO> getTipoPer() {
		// TODO Auto-generated method stub
		return (List<TipoPersonaDTO>)getSqlMapClientTemplate().queryForList("getTipoPersonas");
	}

}
